home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / hc / fortunec.sit / Fortune Cookies / background_2079.txt < prev    next >
Encoding:
Text File  |  1988-11-14  |  6.0 KB  |  234 lines

  1. -- background: 2079 from stack: in
  2. -- bmap block id: 3335
  3. -- flags: 4000
  4. -- background id: 0
  5. -- name: Title
  6. ----- HyperTalk script -----
  7. on openBackground
  8.   push recent card
  9. end openBackground
  10.  
  11.  
  12. -- part 1 (button)
  13. -- low flags: 00
  14. -- high flags: 8003
  15. -- rect: left=29 top=297 right=319 bottom=147
  16. -- title width / last selected line: 0
  17. -- icon id / first selected line: 0 / 0
  18. -- text alignment: 1
  19. -- font id: 0
  20. -- text size: 12
  21. -- style flags: 0
  22. -- line height: 16
  23. -- part name: Import Fortunes
  24. ----- HyperTalk script -----
  25. on mouseUp
  26.   set the cursor to 4
  27.   go to first card
  28.   doMenu "Copy Card"
  29.   go to last card
  30.   doMenu "Paste Card"
  31.   -- unlock the following fields so we can change them
  32.   set lockText of field "Your Fortune" to false
  33.   set lockText of field "Category" to false
  34.   go to card "Control Card"
  35.   repeat with i = 1 to the number of lines in field "Files to Import"
  36.     get line i of field "Files to Import"
  37.     put it into category
  38.     get line 1 of field "Search Path"
  39.     put it & category into fileName
  40.     open file fileName
  41.     read from file fileName for 1 -- get the delimiter character
  42.     put it into delimiter
  43.     read from file fileName until return -- and skip rest of line
  44.     read from file fileName until delimiter
  45.     push card
  46.     go to last card
  47.     repeat until it is empty
  48.       put empty into last char of it -- don't include the delimiter
  49.       put it into field "Your Fortune"
  50.       put category into field "Category"
  51.       doMenu "New Card"
  52.       read from file fileName until return -- and skip rest of line
  53.       read from file fileName until delimiter
  54.     end repeat
  55.     close file fileName
  56.     pop card
  57.   end repeat
  58.   go to last card -- which is blank
  59.   doMenu "Delete Card"
  60.   -- Re-lock fields
  61.   set lockText of field "Your Fortune" of card "Sample Card" to true
  62.   set lockText of field "Category" of card "Sample Card" to true
  63. end mouseUp
  64.  
  65.  
  66.  
  67. -- part 2 (field)
  68. -- low flags: 00
  69. -- high flags: 0007
  70. -- rect: left=25 top=182 right=279 bottom=472
  71. -- title width / last selected line: 0
  72. -- icon id / first selected line: 0 / 0
  73. -- text alignment: 0
  74. -- font id: 3
  75. -- text size: 12
  76. -- style flags: 0
  77. -- line height: 16
  78. -- part name: Files to Import
  79.  
  80.  
  81. -- part 3 (field)
  82. -- low flags: 00
  83. -- high flags: 0002
  84. -- rect: left=25 top=138 right=157 bottom=472
  85. -- title width / last selected line: 0
  86. -- icon id / first selected line: 0 / 0
  87. -- text alignment: 0
  88. -- font id: 3
  89. -- text size: 12
  90. -- style flags: 0
  91. -- line height: 16
  92. -- part name: Search Path
  93.  
  94.  
  95. -- part 4 (button)
  96. -- low flags: 00
  97. -- high flags: 8003
  98. -- rect: left=188 top=297 right=319 bottom=306
  99. -- title width / last selected line: 0
  100. -- icon id / first selected line: 0 / 0
  101. -- text alignment: 1
  102. -- font id: 0
  103. -- text size: 12
  104. -- style flags: 0
  105. -- line height: 16
  106. -- part name: Export Fortunes
  107. ----- HyperTalk script -----
  108. on mouseUp
  109.   -- Initialize some variables
  110.   set the cursor to 4
  111.   put "Exporting fortunes" into field "Import/Export Status"
  112.   show field "Import/Export Status"
  113.   put number of card "Control Card" into firstCard
  114.   add 1 to firstCard
  115.   put empty into category
  116.   put empty into fileName
  117.   put field "Search Path" into searchPath
  118.   put char 1 of field "Delimiter Char" & return into delimiter
  119.   -- Now go through stack and write fortunes to their respective files
  120.   repeat with i = firstCard to the number of cards
  121.     put field "Category" of card i into newCategory
  122.     if newCategory <> category then
  123.       if fileName <> empty then close file fileName
  124.       put newCategory into category
  125.       put searchPath & category into filename
  126.       open file fileName
  127.       put "Exporting " & category & return & "Fortunes exported: 0" into field "Import/Export Status"
  128.       write delimiter to file fileName -- We have to start with delimiter
  129.     end if
  130.     write field "Your fortune" of card i to file fileName
  131.     write delimiter to file fileName
  132.     add 1 to last word of field "Import/Export Status"
  133.   end repeat
  134.   close file fileName -- Close last file opened
  135.   hide field "Import/Export Status"
  136. end mouseUp
  137.  
  138.  
  139.  
  140. -- part 7 (field)
  141. -- low flags: 00
  142. -- high flags: 0002
  143. -- rect: left=453 top=163 right=181 bottom=472
  144. -- title width / last selected line: 0
  145. -- icon id / first selected line: 0 / 0
  146. -- text alignment: 0
  147. -- font id: 3
  148. -- text size: 12
  149. -- style flags: 0
  150. -- line height: 16
  151. -- part name: Delimiter Char
  152.  
  153.  
  154. -- part 8 (button)
  155. -- low flags: 00
  156. -- high flags: 8003
  157. -- rect: left=342 top=297 right=319 bottom=468
  158. -- title width / last selected line: 0
  159. -- icon id / first selected line: 0 / 0
  160. -- text alignment: 1
  161. -- font id: 0
  162. -- text size: 12
  163. -- style flags: 0
  164. -- line height: 16
  165. -- part name: Clear All Fortunes
  166. ----- HyperTalk script -----
  167. on mouseUp
  168.   put number of card "Control Card" into firstCard
  169.   add 1 to firstCard
  170.   repeat while number of cards >= firstCard -- just keep the example card
  171.     go to card firstCard
  172.     doMenu "Delete Card"
  173.   end repeat
  174. end mouseUp
  175.  
  176.  
  177.  
  178. -- part 9 (button)
  179. -- low flags: 00
  180. -- high flags: 8005
  181. -- rect: left=25 top=85 right=107 bottom=203
  182. -- title width / last selected line: 0
  183. -- icon id / first selected line: 0 / 0
  184. -- text alignment: 1
  185. -- font id: 0
  186. -- text size: 12
  187. -- style flags: 0
  188. -- line height: 16
  189. -- part name: Show categories?
  190. ----- HyperTalk script -----
  191. on mouseUp
  192.   get hilite of me
  193.   set hilite of me to not it
  194.   if hilite of me then
  195.     show field "Category" of card "Sample Card"
  196.   else
  197.     hide field "Category" of card "Sample Card"
  198.   end if
  199. end mouseUp
  200.  
  201.  
  202.  
  203. -- part 11 (button)
  204. -- low flags: 00
  205. -- high flags: 0000
  206. -- rect: left=7 top=25 right=47 bottom=43
  207. -- title width / last selected line: 0
  208. -- icon id / first selected line: 1011 / 1011
  209. -- text alignment: 1
  210. -- font id: 0
  211. -- text size: 12
  212. -- style flags: 0
  213. -- line height: 16
  214. -- part name: Home
  215. ----- HyperTalk script -----
  216. on mouseUp
  217.   go to home
  218. end mouseUp
  219.  
  220.  
  221.  
  222. -- part 12 (field)
  223. -- low flags: 80
  224. -- high flags: 0004
  225. -- rect: left=90 top=192 right=233 bottom=416
  226. -- title width / last selected line: 0
  227. -- icon id / first selected line: 0 / 0
  228. -- text alignment: 0
  229. -- font id: 0
  230. -- text size: 12
  231. -- style flags: 0
  232. -- line height: 16
  233. -- part name: Import/Export Status
  234.